package com.wc.fortnight_blue_bridge.Q231019.宝玉出行;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/20 2:16
 * @description https://www.lanqiao.cn/problems/19932/learning/?contest_id=212
 */
public class Main {
    /**
     * 这个k如何判断够不够呢, 是不是判断一个 d 长度的区间 1 的个数就是需要的车的数量, 那么我们去这个最大的就好了
     * 线段树最底层是sum[i] - sum[i - d]中 1 的个数, 反转 i 相当于更新 i ~ i + d- 1这个区间的值
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010, M = N << 2;
    static int[] maxv = new int[M], laz = new int[M];
    static int[] sum = new int[N];
    static int n, d, q;
    static char[] s;

    public static void main(String[] args) {
        n = sc.nextInt();
        d = sc.nextInt();
        s = (" " + sc.next()).toCharArray();
        for (int i = 1; i <= n; i++) {
            if (s[i] == '1') sum[i] = 1;
            sum[i] += sum[i - 1];
        }
        build(1, 1, n);
        q = sc.nextInt();
        while (q-- > 0) {
            int op = sc.nextInt(), x = sc.nextInt();
            if (op == 1) {
                int c = s[x] == '1' ? -1 : 1;
                s[x] = s[x] == '1' ? '0' : '1';
                modify(1, 1, n, x, Math.min(x + d - 1, n), c);
            } else {
                if (maxv[1] <= x) out.println(-1);
                else out.println(query(1, 1, n, x));
            }
        }
        out.flush();
    }

    static void modify(int u, int l, int r, int ql, int qr, int c) {
        if (l == ql && r == qr) {
            laz[u] += c;
            maxv[u] += c;
            return;
        }
        pushDown(u);
        int mid = l + r >> 1;
        if (qr <= mid) modify(u << 1, l, mid, ql, qr, c);
        else if (ql > mid) modify(u << 1 | 1, mid + 1, r, ql, qr, c);
        else {
            modify(u << 1, l, mid, ql, mid, c);
            modify(u << 1 | 1, mid + 1, r, mid + 1, qr, c);
        }
        pushUp(u);
    }

    static int query(int u, int l, int r, int k) {
        if (l == r) {
            return l;
        }
        int mid = l + r >> 1;
        pushDown(u);
        if (maxv[u << 1] > k) return query(u << 1, l, mid, k);
        else return query(u << 1 | 1, mid + 1, r, k);
    }

    static void build(int u, int l, int r) {
        if (l == r) {
            maxv[u] = sum[r] - sum[Math.max(0, r - d)];
            return;
        }
        int mid = l + r >> 1;
        build(u << 1, l, mid);
        build(u << 1 | 1, mid + 1, r);
        pushUp(u);
    }

    static void pushUp(int u) {
        maxv[u] = Math.max(maxv[u << 1], maxv[u << 1 | 1]);
    }

    static void pushDown(int u) {
        if (laz[u] != 0) {
            laz[u << 1] += laz[u];
            laz[u << 1 | 1] += laz[u];
            maxv[u << 1] += laz[u];
            maxv[u << 1 | 1] += laz[u];
            laz[u] = 0;
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
